﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sai.Cecil
{
	public static class StringExtensions
	{
		/// <summary>
		/// Returns non-generic part of the name List'1 returns List
		/// </summary>
		/// <param name="name"></param>
		/// <returns></returns>
 		public static string NonGenericName(this string name)
		{
			string fixedName = name;

			int apostropheIndex = name.IndexOf("`");

			if (apostropheIndex > 0)
			{
				const int StartOfString = 0;
				fixedName = name.Substring(StartOfString, apostropheIndex);
			}

			return fixedName;
		}

        public static string NonByReferenceName(this string name)
        {
            string fixedName = name;

            int ampIndex = name.IndexOf("&");

            if (ampIndex > 0)
            {
                const int StartOfString = 0;
                fixedName = name.Substring(StartOfString, ampIndex);
            }

            return fixedName;
        }

	}
}
